package com.wedo.mall.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.e.library.activity.EActivity;
import com.e.library.adapter.Adapter;
import com.e.library.entity.User;
import com.e.library.listener.EListener;
import com.wedo.mall.R;
import com.wedo.mall.activity.chat.ConsultActivity;
import com.wedo.mall.util.WUrl;

import java.util.List;

/**
 * Created by Lawrence on 2017/7/2.
 */

public class ContactAdapter extends Adapter<User> {

    public ContactAdapter(Context context, List<User> linkmen) {
        super(context, linkmen);
    }

    @Override
    protected int layout() {
        return R.layout.item_contact;
    }

    @Override
    protected void bind(EHolder holder, User user, int position) {
        ImageView iv_headimgurl = holder.find(R.id.iv_headimgurl);
        TextView tv_nickname= holder.find(R.id.tv_nickname);

        tv_nickname.setText(user.nickname);
        String img = WUrl.url(user.headimgurl);
        Glide.with(mContext).load(img).error(R.drawable.ease_default_avatar).placeholder(R.drawable.ease_default_avatar).diskCacheStrategy(DiskCacheStrategy.ALL).into(iv_headimgurl);
    }

    public void listener(final EActivity activity){
        onItemClickListener = new EListener<User>() {
            @Override
            public void onInvoked(View view, User data, int position) {

                ConsultActivity.toConsult(activity,data,"");
            }
        };
    }
}
